#pragma once

#include <string>
#include <vector>
#include <set>

using namespace std;
namespace codewar {

    void worker( std::set<string> & result, std::string line, std::string chars ) {
        if( !chars.empty() ) {
            for( auto x = 0; x < chars.size(); ++x ) {
                worker( result, line + chars[x], std::string( chars ).erase( x, 1 ) );
            }
        } else {
            result.insert( line );
        }
    }

    vector<string> permutations( string s ) {
        std::set<std::string> result;
        worker( result, string(), s );
        return std::vector<std::string>( result.begin(), result.end() );
    }

}
